package com.zzyk.main.utils;


import com.zzyk.main.model.pojo.HttpHelper;
import org.apache.http.HttpException;

import java.io.IOException;

public class TencentAppUtils {
    private static String appId = "wxf1027abcaee87d3d";
    private static String appSecret = "e91db80dc78992082080bf3f5565fba6";
    private static String grant_type = "authorization_code";

    private static String code2SessionUrl = "https://api.weixin.qq.com/sns/jscode2session";

    public static String code2Session(String jsCode) throws IOException, HttpException {
        HttpHelper httpHelper = new HttpHelper();
        httpHelper.setParams("appid", appId);
        httpHelper.setParams("secret", appSecret);
        httpHelper.setParams("js_code", jsCode);
        httpHelper.setParams("grant_type", grant_type);
        return HttpUtils.request(code2SessionUrl, "GET", httpHelper);
    }
}
